{extend name="user_base" /} {block name="seo"}
<title>注册账号 - {$site_config['seo_title']}</title>
<meta name="keywords" content="{$site_config['seo_keyword']}">
<meta name="description" content="{$site_config['seo_description']}">
{/block}
{block name="css"}
{/block}
{block name="body"}
<div class="page page-current us-w" id="reg">
    <!-- 这里是页面内容区 -->
    <div class="content">
        <header id="header" class="clearfix theader baise">
            <a href="/" class="back iconfont icon-fanhui"></a>
            <h3 class="titlea">注册账号</h3>
        </header>
        <form action="" id="registerForm" method="post">
            <div class="inline clearfix">
                <i class="iconfont icon-zhanghao"></i>
                <input type="text" id="username" name="username" placeholder="请输入您的手机或邮箱" />
            </div>
            <div class="inline layui-clear code">
                <i class="iconfont icon-yanzhengma"></i>
                <input type="text" placeholder="右侧验证码" name="captcha" id="captcha" autocomplete="off" maxlength="4"
                       style="width:calc(100% - 6rem - 3rem);" >
                <img src="{:url('index/page/captcha')}?'+Math.random();" title="点击可刷新图形码" onclick="this.src='{:url(\'index/page/captcha\')}?_='+Math.random()"  class="imgcode" />
            </div>
            <div class="inline layui-clear">
                <i class="iconfont icon-yanzhengma"></i>
                <input type="text" name="smscode" lay-verify="smscode" placeholder="验证码" maxlength="6"
                       style="width:calc(100% - 120px - 70px);"/>
                <div class="item-title label">
                    <a href="#" id="sendCodeBtn" style="line-height: 45px;">发送验证码</a>
                </div></div>
            <div class="inline clearfix">
                <i class="iconfont icon-mima"></i>
                <input type="password" name="password" placeholder="请输入您的密码" />
            </div>
            <div class="loo clearfix">
                {if $site_config.qqlogin_status eq 1}
                <div class="ks">
                    <a href="/user/qqlogin.html"><img src="//static.115z.com/img/qq.png"></a>
                </div>
                {/if}
                <div class="zc">
                    <a href="/user/login.html">我已有账号了</a>
                </div>
            </div>
            <button class="btn">立即注册</button>
        </form>
    </div>
</div>
<script src="__PUBLIC__/plugins/layui/layui.js"></script>
<script type="text/javascript">
    layui.use('form', function () {
        var $ = layui.jquery;
        $('#sendCodeBtn').on('click', function () {
            var obj = $(this);
            var options = {
                seconds: 60
                , type: 'REG'
                , object: $('#username').val()
                , captcha: $('#captcha').val()
            };

            if ($.trim(options.object) == '') {
                layer.msg('手机号或邮箱必填');
                return false;
            }

            if ($.trim(options.captcha) == '') {
                layer.msg('图形码必填');
                return false;
            }
            var url = config.api.send_code;
            $.post(url, options, function (data) {
                if (data.code == 1) {
                    layer.msg(data.msg);
                    countDown(60, obj);
                } else {
                    layer.alert(data.msg);
                    $('#captchaPic').trigger("click");
                }
            });
        });

        function countDown(seconds, obj) {

            if (seconds > 1) {

                seconds--;

                $(obj).attr('disabled', true).html(seconds + "s");//禁用按钮

                // 定时1秒调用一次

                setTimeout(function () {

                    countDown(seconds, obj);

                }, 1000);

            } else {

                $(obj).attr('disabled', false).html("获取验证码");//启用按钮

            }
        }


    });
</script>
{/block}
